package com.hzl;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import com.yao.component.circle.R;

/**
 * Created by hzl on 2016/1/14.
 */
public class PictureDialog extends Dialog {

    private final Context context;
    private onPictureDialogListener mListener;
    public PictureDialog(Context context,onPictureDialogListener listener) {
        super(context, R.style.DialogWhite);
        this.context = context;
        this.mListener=listener;
        setCanceledOnTouchOutside(true);
        Window window = this.getWindow();
        window.setGravity(Gravity.BOTTOM);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View inflate = LayoutInflater.from(context).inflate(R.layout.activity_picture, null);
        inflate.setMinimumWidth(10000);
        setContentView(inflate);
        findViewById(R.id.choice_camare).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mListener!=null){
                    mListener.onCamare();
                }
            }
        });
        findViewById(R.id.choice_picture).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mListener!=null){
                    mListener.onAlbum();
                }

            }
        });
        findViewById(R.id.cancle).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mListener!=null){
                    mListener.onCancle();
                }
            }
        });
    }

    @Override
    public void show() {
        super.show();
    }
    public interface onPictureDialogListener{
        public void onCamare();
        public void onAlbum();
        public void onCancle();
    }
}
